package com.css.db.util;

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;

public class DBConfigUtil {

	public static NamedNodeMap readDbConfig() {
		NamedNodeMap map = null;
		try {
			File f = new File("src/main/webapp/META-INF/context.xml");
			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = factory.newDocumentBuilder();
			Document doc = builder.parse(f);
			NodeList nl = doc.getElementsByTagName("Resource");
			for (int i = 0; i < nl.getLength(); i++) {
				map = nl.item(i).getAttributes();
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

		return map;
	}

}
